package com.sf.wisdomkg.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sf.wisdomkg.R;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by Administrator on 2017/8/29.
 */
public class TalkingParentListViewAdapter extends BaseAdapter{
    private Context context;
    private ArrayList<HashMap<String, String>> list;

    public TalkingParentListViewAdapter(Context context, ArrayList<HashMap<String,String>> data_list) {
        this.context = context;
        this.list = data_list;

    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list == null ? 0 : list.size();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    public View getView(int position, View convertView, ViewGroup arg2) {
        // TODO Auto-generated method stub
        LayoutInflater inflater = LayoutInflater.from(context);
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = inflater.inflate(R.layout.talking_parent_list_item,null);
            viewHolder.username= (TextView) convertView.findViewById(R.id.username);
            viewHolder.phone= (TextView) convertView.findViewById(R.id.phone);


            convertView.setTag(viewHolder);

        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.username.setText(list.get(position).get("children")+"的家长");
        viewHolder.phone.setText("电话："+list.get(position).get("phone"));

        return convertView;
    }
    public class ViewHolder{
        TextView username,phone;

    }
}
